use std::sync::LazyLock;
use std::time::Duration;
use tower_http::cors;
use tower_http::cors::CorsLayer;

static CORS_LAYER: LazyLock<CorsLayer> =  LazyLock::new(|| {
    CorsLayer::new()
        .allow_origin(cors::Any)
        .allow_methods(cors::Any)
        .allow_headers(cors::Any)
        .allow_credentials(false)
        .max_age(Duration::from_secs(3600 * 12))
});


/// 跨域中间件
pub fn get_cors_layer() -> &'static CorsLayer {
    &CORS_LAYER
}
